<template>
<view class="about">
	<view style="height: 2118upx; position: relative;">
		<image src="../../static/jmbg.png" style="width: 100%; height: 2118upx;"></image>
		<input @input="inputName" type="text" id="name" placeholder="如何称呼您" style="width: 618upx; height: 73upx; position: absolute; left: 66upx; 
			bottom: 510upx; z-index: 5; border-radius: 20upx; font-size: 26upx; background: #fff; padding: 0 30upx; box-sizing: border-box;"/>
		<input @input="inputPhone" type="text" id="phone" placeholder="您的联系方式" style="width: 618upx; height: 73upx; position: absolute; left: 66upx; 
			bottom: 390upx; z-index: 5; border-radius: 20upx; font-size: 26upx; background: #fff; padding: 0 30upx; box-sizing: border-box;"/>
		<view style="width: 400upx; height: 110upx; line-height: 110upx; box-shadow: 0upx 3upx 17upx 1upx rgba(239, 146, 98, 0.33); color: #f57f3b;
			font-size: 40upx; background: #fff; text-align: center;  position: absolute; left: 175upx; bottom: 100upx; border-radius: 55upx;" @click="submit">提交</view>
		<view style="text-align: center; color: #ffffff; font-size: 24upx; text-decoration: underline; width: 100%; position: absolute; 
			bottom: 30upx; line-height: 2;" @click="callPhone">直接拨打客服电话：400-003-9881</view>		
	</view>
</view>
</template>

<script>
import { HTTP } from '../../http.js';
let http = new HTTP;
export default {
	data() {
		return {
			name: '',
			phone: ''
		}
	},
	methods: {
		inputName(e) {
			this.name = e.target.value;			
		},
		inputPhone(e) {
			this.phone = e.target.value;			
		},
		submit() {
			let name = this.name;
			let phone = this.phone;
			if( name.replace(/\s/g,'') == '' || phone.replace(/\s/g,'') == '' ){
				uni.showToast({ icon: 'none', title: '请完善您的姓名和电话，以便我们联系您。', duration: 2000 });
			}else{
				let user = uni.getStorageSync('user');
				uni.showLoading({ title: '加载中' });
				http.request({
					url: `UserFeedbackController/addUserFeedback?a=a`,
					method: 'post',
					data: { guestbook: `电话:${ phone },${ name }有意向加盟`, status: 0, userId: user.userId },
					success: (res)=>{				
						uni.hideLoading();
						uni.navigateBack({ delta: 1, success: ()=>uni.showToast({ icon: 'none', title: '我们已经收到您的信息，会尽快跟您取得联系。', duration: 2000 }) });
					},
					fail: ()=>{								
						uni.hideLoading();
					}
				});				
			}				
		},
		callPhone() {
			uni.makePhoneCall({ phoneNumber: '400-003-9881' });
		}
	},
	onLoad() {}
}
</script>

<style>
.about {
	width: 100%; 
	height: 100vh;
	overflow: auto;
	background: #f47e3e;
}
</style>
